<template>
  <div class="gallery" @click="handleGalleryClick">
    <swiper class="wrapper" :options="swiperOptions">
      <swiper-slide v-for="item in imgs" :key="item.id">
        <img class="gallery-img" :src="item">
      </swiper-slide>
      <div class="swiper-pagination" slot="pagination"></div>
    </swiper>
  </div>
</template>

<script>
export default {
  props: {
    imgs: {
      type: Array,
      deafault () {
        return []
      }
    }
  },
  data () {
    return {
      swiperOptions: {
        pagination: '.swiper-pagination',
        paginationType: 'fraction',
        observeParents: true,
        observer: true
      }
    }
  },
  methods: {
    handleGalleryClick () {
      this.$emit('close')
    }
  }
}
</script>

<style lang="stylus" scoped>
  .gallery
    z-index 999
    position absolute
    top 0
    left 0
    right 0
    bottom 0
    background #000
    display flex
    align-items center
    .gallery-img
      width 100%
    .swiper-pagination
      position: fixed;
      bottom: 1.4rem;
      font-size: .32rem;
      color: #fff;
      font-weight: normal
</style>
